<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/base/headcss.jsp"%>
<!DOCTYPE html>
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>新增用户</title>
	<style type="text/css">
		.center-vertical {
		    position:relative;
		    top:50%;
		    transform:translateY(50%);
		}
	 
	</style>
	</head>
	<body>
 
		<div  class="row center-vertical "   >
			<div class="col-md-4 col-md-offset-4   text-center">
			 
				<form class="form-horizontal" id="form1">
					  <div class="form-group">
					    <label for="inputUserName" class="col-sm-2 control-label">用户名:</label>
					    <div class="col-sm-10">
					      <input type="text" name="username"  class="form-control " id="inputUserName" placeholder="请输入用户名">
					    </div>
					  </div>
					  <div class="form-group">
					    <label for="inputPassword3" class="col-sm-2 control-label">密 码:</label>
					    <div class="col-sm-10">
					      <input type="password" name="password" class="form-control  " id="inputPassword3" placeholder="请输入密码">
					    </div>
					  </div>
					   <div class="form-group">
					    <label for="inputEmail3" class="col-sm-2 control-label">邮 箱:</label>
					    <div class="col-sm-10">
					      <input type="email" class="form-control  "   name="email" id="inputEmail3" placeholder="请输入邮箱">
					    </div>
					  </div>
					  <div class="form-group">
					    <div class="col-sm-offset-2 col-sm-10">
					       <input type="button"  class="btn btn-sm btn-primary" value="添加用户" onclick="adduser();">&nbsp;
	       			 		 <input type="reset"  class="btn btn-sm"  value="重置">
					    </div>
					  </div>
					</form>
					
			</div>
			
		</div>
	  <script type="text/javascript" src="<c:url value="/scripts/jQuery/jquery-1.10.2.min.js"/>" ></script>
	  <script type="text/javascript">
        function adduser() {
            $.ajax({
            //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "text",//预期服务器返回的数据类型
                url: "<c:url value='/sysuser/save'/>" ,//url
                data: $('#form1').serialize(),
                success: function (data) {
                    
                    if (data == "success") {
                        alert("添加成功");
                    }else{
                    	alert(data);
                    }
                },
                error : function() {
                    alert("添加失败！");
                }
            });
        }
    </script>
	</body> 

</html>